package com.damon.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

import java.io.InputStream;
import java.util.zip.ZipInputStream;

public class ActivitiDeployment {
    public static void main(String[] args) {
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

        RepositoryService repositoryService = processEngine.getRepositoryService();

        // 3.转化出ZipInputStream流对象
        InputStream inputStream = ActivitiDeployment.class.getClassLoader().getResourceAsStream("diagram/holidayBpm.zip");

        // 将inputStream流转化为ZipInputStream流
        ZipInputStream zipInputStream = new ZipInputStream(inputStream);



        Deployment deployment = repositoryService.createDeployment()
//                .addClasspathResource("diagram/holiday.bpmn")
//                .addClasspathResource("diagram/holiday.png")
                .addZipInputStream(zipInputStream)
                .name("ask for name")
                .deploy();
        System.out.println(deployment.getName());
        System.out.println(deployment.getId());
        System.out.println(deployment.getKey());
    }
}
